<?php 
$server = new swoole_websocket_server("0.0.0.0", 9502);
$server->on('message', function (swoole_websocket_server $server, $frame) {
	if(memory_get_usage()>100*1024*1024){
	    exit(0);//大于100M内存退出程序，防止内存泄漏被系统杀死导致任务终端
	}
	$redis=new Redis();
	$redis->pconnect('127.0.0.1',6379);
	$server->push($frame->fd,json_encode($redis->hGetAll($frame->data)));
});
$server->start();
 ?>
